import java.util.Arrays;

public class Task {

    public static void main(String[] args) {
        // 输出 "Hello X World X"
        System.out.println(replaceX("Hello 123 World 456"));

        // 输出 ["Hello", "123", "World", "456"]
        System.out.println(splitBySpace("Hello  123 World     456"));

        // 输出：不许笑，打个劫！
        System.out.println(removeDuplicate("不不许许许许许笑笑笑，打打打打打打打打打个劫劫劫！"));
    }

    // 去掉重复的字并返回
    public static String removeDuplicate(String input) {
        return input.replaceAll("(.)\\1+", "$1");
    }

    // 按空格分割字符串并返回
    public static String splitBySpace(String input) {
        String pattern = "\\s+";
        String[] parts = input.split(pattern);
        return Arrays.toString(parts);
    }

    // 将所有连续出现的数字替换成字母X并返回
    public static String replaceX(String input) {
        String pattern = "\\d+";
        String replacement = "X";
        return input.replaceAll(pattern, replacement);
    }


}